using System;
using RockHopper.Common.Model;

namespace RockHopper.Common.Services
{
    public class CalculationService : ICalculationService
    {
        public CalculationContext Calculate(double vdot)
        {
            var calculator = new VdotCalculator();
            var context = new CalculationContext {Vdot = vdot};
            calculator.Calculate(context);
            return context;
        }

        public double RaceTime(double vdot, double distance)
        {
            var calculator = new VdotCalculator();
            double raceTime;
            return calculator.RaceTime(vdot, distance, out raceTime) ? raceTime : 0;
        }

        public HeartRateZones CalculateHeartRateZones(int resting, int maximum)
        {
            return HeartRateZones.Create(resting, maximum);
        }
    }
}